package com.ruoyi.keep.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.keep.domain.WxWallet;
import com.ruoyi.keep.service.IWxWalletService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 微信钱包Controller
 * 
 * @author wxy
 * @date 2024-08-16
 */
@RestController
@RequestMapping("/keep/wallet")
public class WxWalletController extends BaseController
{
    @Autowired
    private IWxWalletService wxWalletService;

    /**
     * 查询微信钱包列表
     */
    @PreAuthorize("@ss.hasPermi('keep:wallet:list')")
    @GetMapping("/list")
    public TableDataInfo list(WxWallet wxWallet)
    {
        startPage();
        List<WxWallet> list = wxWalletService.selectWxWalletList(wxWallet);
        return getDataTable(list);
    }

    /**
     * 导出微信钱包列表
     */
    @PreAuthorize("@ss.hasPermi('keep:wallet:export')")
    @Log(title = "微信钱包", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WxWallet wxWallet)
    {
        List<WxWallet> list = wxWalletService.selectWxWalletList(wxWallet);
        ExcelUtil<WxWallet> util = new ExcelUtil<WxWallet>(WxWallet.class);
        util.exportExcel(response, list, "微信钱包数据");
    }

    /**
     * 获取微信钱包详细信息
     */
    @PreAuthorize("@ss.hasPermi('keep:wallet:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wxWalletService.selectWxWalletById(id));
    }

    /**
     * 新增微信钱包
     */
    @PreAuthorize("@ss.hasPermi('keep:wallet:add')")
    @Log(title = "微信钱包", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxWallet wxWallet)
    {
        return toAjax(wxWalletService.insertWxWallet(wxWallet));
    }

    /**
     * 修改微信钱包
     */
    @PreAuthorize("@ss.hasPermi('keep:wallet:edit')")
    @Log(title = "微信钱包", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxWallet wxWallet)
    {
        return toAjax(wxWalletService.updateWxWallet(wxWallet));
    }

    /**
     * 删除微信钱包
     */
    @PreAuthorize("@ss.hasPermi('keep:wallet:remove')")
    @Log(title = "微信钱包", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wxWalletService.deleteWxWalletByIds(ids));
    }
}
